package com.config;

import org.springframework.boot.autoconfigure.AutoConfigurationImportEvent;
import org.springframework.boot.autoconfigure.AutoConfigurationImportListener;

import java.util.List;
import java.util.Set;

/**
 * @author chengyadong
 * @date 2023/9/18 16:30
 * @description 自动配置类监听端口
 */
public class AutoConfigurationImportListenerPrinter implements AutoConfigurationImportListener {
	//该方法会在自动配置类筛选完成后通过发布AutoConfigurationImportEvent事件进行调用
	@Override
	public void onAutoConfigurationImportEvent(AutoConfigurationImportEvent event) {
		//自动配置类最终符合条件的导入类集合
		List<String> candidateConfigurations = event.getCandidateConfigurations();
		for (String candidateConfiguration : candidateConfigurations) {
			System.out.println("符合条件装配的自动配置类：="+candidateConfiguration);
		}
		//自动配置类中排除的集合    （两者合并即为最初加载的导入类集合）
		Set<String> exclusions = event.getExclusions();
	}
}
